// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class GENERAL_ORDER_ORL_O22 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("15 CONTAINER",15)]
  	    [HL7Field(HL7Version.v24, 15, HL7Repeat.False, HL7Required.False,"CONTAINER_ORL_O22")]
	    public CONTAINER_ORL_O22 CONTAINER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("23 ORDER",23)]
  	    [HL7Field(HL7Version.v24, 23, HL7Repeat.False, HL7Required.False,"ORDER_ORL_O22")]
	    public ORDER_ORL_O22 ORDER {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			CONTAINER = ProcessGroup<CONTAINER_ORL_O22>(availableData, options, "CONTAINER");
			ORDER = ProcessGroup<ORDER_ORL_O22>(availableData, options, "ORDER");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			CONTAINER_ORL_O22 testCONTAINER_ORL_O22 = new CONTAINER_ORL_O22();
			bool grpCCCONTAINER_ORL_O22 = (testCONTAINER_ORL_O22.CanConsume(availableData, options));
			if (IsRequired("CONTAINER", options.Version) || grpCCCONTAINER_ORL_O22) {
				return grpCCCONTAINER_ORL_O22;
			}
			ORDER_ORL_O22 testORDER_ORL_O22 = new ORDER_ORL_O22();
			bool grpCCORDER_ORL_O22 = (testORDER_ORL_O22.CanConsume(availableData, options));
			if (IsRequired("ORDER", options.Version) || grpCCORDER_ORL_O22) {
				return grpCCORDER_ORL_O22;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "GENERAL_ORDER";
			}
        }

        static GENERAL_ORDER_ORL_O22() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(GENERAL_ORDER_ORL_O22));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (CONTAINER != null) {
			string segmentValue = CONTAINER.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ORDER != null) {
			string segmentValue = ORDER.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

